<?php

set_include_path(implode(PATH_SEPARATOR,
    array(
        get_include_path(),
        '..',
        dirname(dirname(__FILE__))
    )));

require_once 'components/utils/debug_utils.php';

Warning::BeginSuppress(PHPWarning::$Deprecated);
Warning::BeginSuppress(PHPWarning::$Strict);

require_once 'simpletest/autorun.php';
require_once 'database_engine/dataset_metadata.php';

class TableMetadataTests extends UnitTestCase
{
    public function testCreateUpdateCommand()
    {
        $tableMetadata = new TableMetadata('test_table', array(
            'id' => 'integer',
            'value' => 'string'
        ));

        $command = $tableMetadata->CreateUpdateCommand();

        $command->SetParameterValue('[id]', '2');
        $command->SetParameterValue('[value]', 'string val');

        $command->SetParameterValue('[id]', '1', ParamType::PreviousValue);

        $this->assertEqual(
            'UPDATE test_table SET id = 2, value = \'string val\' WHERE id = 1',
            $command->GetSql()
        );
    }
}

?>